package MyWizard;



import java.awt.EventQueue;
import java.awt.Rectangle;
import java.util.List;
import java.util.Map;
import org.netbeans.api.wizard.WizardDisplayer;
import org.netbeans.spi.wizard.DeferredWizardResult;
import org.netbeans.spi.wizard.ResultProgressHandle;
import org.netbeans.spi.wizard.Summary;
import org.netbeans.spi.wizard.Wizard;
import org.netbeans.spi.wizard.WizardException;
import org.netbeans.spi.wizard.WizardPage;
import preferences.Database.Column;
import preferences.Database.DBInterface;


public class WizardDemo {
    public static DBInterface db;
    public static String table;
    public static List<Column> columns;
    
    public static void main(String[] args) {
        final Class[] pages = new Class[]{
            Page0.class, Page1.class, Page2.class, Page3.class
        };

        Runnable r;
        r = new Runnable() {

            public void run() {
                MyProducer mp = new MyProducer();
                Wizard wizard = WizardPage.createWizard(pages, mp);
/*
                try {
                    UIManager.put("wizard.sidebar.image", ImageIO.read(new File("F:\\NetBeansProjects\\PreferencesFramework\\img.gif")));
                } catch (IOException ex) {
                    Logger.getLogger(MyWizardDemo1.class.getName()).log(Level.SEVERE, null, ex);
                }
*/
                WizardDisplayer.showWizard(wizard,new Rectangle(800, 600));
                //System.out.println ("Result = "+WizardDisplayer.showWizard (wizard));
                System.exit(0);
            }
        };

        EventQueue.invokeLater(r);
    }

    public static String getWhere(){
        String where = "true";
        for(Column col : columns ){
            if(col.getOp()!=null && col.getType()!=null)
                if(col.getType().equals("varchar") || col.getType().equals("text"))
                    where+=" AND "+col.getName()+col.getOp().toString()+"'"+col.getValue()+"'";
                else
                    where+=" AND "+col.getName()+col.getOp().toString()+col.getValue();
        }
        return where;
    }
}
class MyProducer implements WizardPage.WizardResultProducer {

    public Object finish(Map wizardData) throws WizardException {
        System.out.println("finish called");
        //System.out.println(wizardData);
        return new Result();
    }

    public boolean cancel(Map settings) {
        System.out.println("cancel called");
        System.out.println(settings);

        return true; // Allow the user to cancel the wizard.
    }
}

class Result extends DeferredWizardResult {

    public Result() {
        // Uncomment the following line to make it possible to close the dialog
        // while the operation is running (abort the operation, in other words).
        // super (true);
    }

    public void start(Map settings, ResultProgressHandle progress) {
        String[] items = new String[1];
        //items[0] = settings.get("db").toString();
        // Replace null with an object reference to have this object returned
        // from the showWizard() method.

        progress.finished(Summary.create(items, null));
    }

}
